package test;

import java.io.IOException;
import java.util.Vector;

public class BPNeuralNetworks {
	 
	static Double[][] sample= 
	{ 
	    {0.0,0.0,0.0,0.0}, 
	    {5.0,1.0,4.0,19.020}, 
	    {5.0,3.0,3.0,14.150}, 
	    {5.0,5.0,2.0,14.360}, 
	    {5.0,3.0,3.0,14.150}, 
	    {5.0,3.0,2.0,15.390}, 
	    {5.0,3.0,2.0,15.390}, 
	    {5.0,5.0,1.0,19.680}, 
	    {5.0,1.0,2.0,21.060}, 
	    {5.0,3.0,3.0,14.150}, 
	    {5.0,5.0,4.0,12.680}, 
	    {5.0,5.0,2.0,14.360}, 
	    {5.0,1.0,3.0,19.610}, 
	    {5.0,3.0,4.0,13.650}, 
	    {5.0,5.0,5.0,12.430}, 
	    {5.0,1.0,4.0,19.020}, 
	    {5.0,1.0,4.0,19.020}, 
	    {5.0,3.0,5.0,13.390}, 
	    {5.0,5.0,4.0,12.680}, 
	    {5.0,1.0,3.0,19.610}, 
	    {5.0,3.0,2.0,15.390}, 
	    {1.0,3.0,1.0,11.110}, 
	    {1.0,5.0,2.0,6.521}, 
	    {1.0,1.0,3.0,10.190}, 
	    {1.0,3.0,4.0,6.043}, 
	    {1.0,5.0,5.0,5.242}, 
	    {1.0,5.0,3.0,5.724}, 
	    {1.0,1.0,4.0,9.766}, 
	    {1.0,3.0,5.0,5.870}, 
	    {1.0,5.0,4.0,5.406}, 
	    {1.0,1.0,3.0,10.190}, 
	    {1.0,1.0,5.0,9.545}, 
	    {1.0,3.0,4.0,6.043}, 
	    {1.0,5.0,3.0,5.724}, 
	    {1.0,1.0,2.0,11.250}, 
	    {1.0,3.0,1.0,11.110}, 
	    {1.0,3.0,3.0,6.380}, 
	    {1.0,5.0,2.0,6.521}, 
	    {1.0,1.0,1.0,16.000}, 
	    {1.0,3.0,2.0,7.219}, 
	    {1.0,5.0,3.0,5.724} 
	}; 
	 
	public static void main( String[] args ) throws IOException
	{
	    Vector<Data> data = new Vector<Data>(); 
	    System.out.println(sample.length);
	    for(int i = 0; i < sample.length; i++)
	    {
	        Data t = new Data();
	        for(int j = 0; j < 3; j++)
	            t.x.add(sample[i][j]);
	        t.y.add(sample[i][3]);
	        data.add(t);
	    }
	    BPNN bp = new BPNN();
	    bp.GetData(data);
	    bp.Train();
	 
	    while(true)
	    {
	        Vector<Double> in = new Vector<Double>(); 
	        for(int i = 0; i < 3; i++)
	        {
	        	Double v = 0.0;
	            in.add(v);
	        }
	        Vector<Double> ou;
	        ou = bp.ForeCast(in);
	        System.out.println(ou.get(0));
	    }
	}

}
